﻿using Furion.DependencyInjection;
using Queer.AutoJob.Core.Entity;
using Queer.AutoJob.Core.Model;
using Queer.AutoJob.Core.Service;
using Queer.Util;
using Queer.Util.Model;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Queer.AutoJob.Core.Business
{
    /// <summary>
    /// 创 建：
    /// 日 期：2021-04-01 09:15
    /// 描 述：定时任务业务类
    /// </summary>

    public class AutoJobBLL : IAutoJobBLL, ITransient
    {
        private readonly IAutoJobService _autoJobService;

        public AutoJobBLL(IAutoJobService autoJobService)
        {
            _autoJobService = autoJobService;
        }

        #region 获取数据

        public async Task<TData<List<AutoJobEntity>>> GetList(AutoJobListParam param)
        {
            TData<List<AutoJobEntity>> obj = new TData<List<AutoJobEntity>>();
            obj.Data = await _autoJobService.GetList(param);
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<List<AutoJobEntity>>> GetPageList(AutoJobListParam param, Pagination pagination)
        {
            TData<List<AutoJobEntity>> obj = new TData<List<AutoJobEntity>>();
            obj.Data = await _autoJobService.GetPageList(param, pagination);
            obj.Total = pagination.TotalCount;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<AutoJobEntity>> GetEntity(long id)
        {
            TData<AutoJobEntity> obj = new TData<AutoJobEntity>();
            obj.Data = await _autoJobService.GetEntity(id);
            obj.Tag = 1;
            return obj;
        }

        #endregion

        #region 提交数据

        public async Task<TData<string>> SaveForm(AutoJobEntity entity)
        {
            TData<string> obj = new TData<string>();
            await _autoJobService.SaveForm(entity);
            obj.Data = entity.Id.ParseToString();
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData> DeleteForm(string ids)
        {
            TData obj = new TData();
            await _autoJobService.DeleteForm(ids);
            obj.Tag = 1;
            return obj;
        }

        #endregion
    }
}